<style>
    .unread{
        background-color: #eff9ff;
    }
    .save span{
        color: #ccc;
    }
    .acbt button{
        background:none;
        border: none;
    }
    .acbt button:hover{
        color: #11a1fd;
    }
</style>
<!-- Page Title Start -->
<div class="row">
    <div class="col xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
        <div class="page-title-wrapper">
            <div class="page-title-box">
                <h4 class="page-title bold">消息中心</h4>
            </div>
        </div>
    </div>
</div>
<!-- Products view Start -->

<div class="row">
    <div class="col-lg-3 col-md-4">
        <div class="row">
            <div class="card col-12">
                <div class="card-header">
                    <a href="./sendmess.php" class="btn btn-primary squer-btn" >
                        <i class="fas fa-file-signature"></i>&nbsp;&nbsp;发消息
                    </a>
                </div>
                <div class="card-body">
                    <ul class="inbox-menu">
                        <li class="mt-0">
                            <a href="?pagenow=1" <?=empty($_SESSION['checkCate']) ? 'class="text-primary bold"':'' ?> >
                            <i class="fas fa-download"></i>信箱
                            <?if(sizeof($longshowunread)>0){?>
                            <span class="mail-count text-danger bold">(<?=sizeof($longshowunread)?>)</span>
                            <?}?>
                            </a>
                        </li>
                        <li>
                            <a href="?pagenow=1&check=star" <?=$_SESSION['checkCate']=='star' ? 'class="text-primary bold"':'' ?>  ><i class="far fa-star"></i>收藏</a>
                        </li>
                        <li>
                            <a href="?pagenow=1&check=save" <?=$_SESSION['checkCate']=='save' ? 'class="text-primary bold"':'' ?> >
                            <i class="far fa-file-alt"></i>草稿
                            <?if($longshowsave>0){?>
                            <span class="mail-count text-danger bold">（<?=$longshowsave?>）</span>
                            <?}?>
                            </a>
                        </li>
                        <li>
                            <a href="?pagenow=1&check=send" <?=$_SESSION['checkCate']=='send' ? 'class="text-primary bold"':'' ?> ><i class="fas fa-upload"></i>已发送</a>
                        </li>
                        <li>
                            <a href="?pagenow=1&check=trash" <?=$_SESSION['checkCate']=='trash' ? 'class="text-primary bold"':'' ?> >
                            <i class="far fa-trash-alt"></i>回收站
                            <?if(sizeof($longshowtrash)>0){?>
                            <span class="mail-count text-danger bold">（<?=sizeof($longshowtrash)?>）</span>
                            <?}?>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="card col-12">
                <div class="card-header">
                    <h4 class="card-title mb-0">最近联系</h4>
                </div>
                <div class="card-body d-flex justify-content-around flex-md-wrap">
                    <? foreach($LCUI as $val){ ?>
                    <div class="d-flex flex-column ml-3 mr-3 mb-3 text-center">
                        <a href="./sendmess.php?gettoid=<?=$val[0]?>" class="user-info">
                            <? if(!empty($val[2])){ ?>
                            <img src="../../uploads/userpic/<?=$val[2] ?>" alt="" class="user-img" ;">
                            <?}else{ ?>
                            <img alt="" class="user-img" style="background-color:<?=random_color() ?> ;">
                            <?} ?>
                        </a>
                        <span><?=$val[1]?></span>
                    </div>
                    <? } ?>
                    <?=count($LCUI)==0 ? '最近暂无联系其他人':''?>
                </div>
            </div>
        </div>
    </div>

    <div class="col-lg-9 col-md-8">
        <?=actionMessShowTips($_SESSION['actionMessShowTips'],$_SESSION['actionMesstipsType']); ?>
        <div class="card">
            <div class="card-body pb-0">
                <div class="email-header">
                    <div class="row">
                        <div class="col top-action-left">
                            <div class="float-left">
                                <? if($_SESSION['checkCate']!='save'){?>
                                <? if($_SESSION['checkCate']!='send'){?>
                                <!--过滤-->
                                <? if($_SESSION['checkCate']!='trash'){?>
                                <div class="btn-group dropdown-action">
                                    <button type="button" class="btn btn-primary squer-btn dropdown-toggle" data-toggle="dropdown">过滤</button>
                                    <div class="dropdown-menu">
                                        <a class="dropdown-item" href="?pagenow=1&searchvalue=<?=$remsearchvalue?>&check=<?=$_SESSION['checkCate']?>">所有</a>
                                        <div class="dropdown-divider"></div>
                                        <a class="dropdown-item" href="?pagenow=1&searchvalue=<?=$remsearchvalue?>&check=<?=$_SESSION['checkCate']?>&filter=read">已读</a>
                                        <a class="dropdown-item" href="?pagenow=1&searchvalue=<?=$remsearchvalue?>&check=<?=$_SESSION['checkCate']?>&filter=unread">未读</a>
                                    </div>
                                </div>
                                <?}?>
                                <!--操作-->
                                <div class="btn-group dropdown-action">
                                    <button type="button" class="btn btn-primary squer-btn dropdown-toggle" data-toggle="dropdown">操作</button>
                                    <div class="dropdown-menu">
                                        <? if($_SESSION['checkCate']!='trash'){?>
                                        <a class="dropdown-item" onclick="SignActionMessage('reply')" href="#">回复</a>
                                        <a class="dropdown-item" onclick="SignActionMessage('forward')" href="#">转发</a>
                                        <div class="dropdown-divider"></div>
                                        <a class="dropdown-item" onclick="mulActionMessage('read','<?=$ListTotal ?>' , '<?=$pageTotal?>')" href="#">标记已读</a>
                                        <a class="dropdown-item" onclick="mulActionMessage('unread','<?=$ListTotal ?>' , '<?=$pageTotal?>')" href="#">标记未读</a>
                                        <div class="dropdown-divider"></div>
                                        <a class="dropdown-item" onclick="mulActionMessage('move','<?=$ListTotal ?>' , '<?=$pageTotal?>')" href="#">删除</a>
                                        <? }else{ ?>
                                        <a class="dropdown-item" onclick="mulActionMessage('back','<?=$ListTotal ?>' , '<?=$pageTotal?>')" href="#">复原</a>
                                        <a class="dropdown-item" onclick="mulActionDelMessage('del',null,'<?=$ListTotal ?>' , '<?=$pageTotal?>')" href="#">清除</a>
                                        <? }?>
                                    </div>
                                </div>
                                <?}?>
                                <?}?>
                                <!--搜索-->
                                <div class="btn-group dropdown-action mail-search">
                                    <form method="get" action="">
                                        <input type="hidden" value="1" name="pagenow" >
                                        <input type="hidden" value="<?=$_SESSION['checkCate'] ?>" name="check">
                                        <input type="hidden" value="<?=$_SESSION['filter']?>" name="filter">
                                        <input type="text" placeholder="在此输入后回车搜索主题" class="form-control search-message" name="searchvalue">
                                    </form>
                                </div>
                            </div>
                        </div>
                        <!--分页-->
                        <? if($ListTotal>0){?>
                        <div class="col-auto top-action-right">
                            <div class="ad-inbox-list">
                                <div class="text-right">
                                    <div class="btn-group">
                                        <? if($pageNow==1){ ?>
                                        <a class="btn btn-white disabled"><i class="fas fa-angle-left"></i></a>
                                        <? }else{ ?>
                                        <a href="?pagenow=<?=$rempagenow-1?>&searchvalue=<?=$remsearchvalue?>&check=<?=$_SESSION['checkCate']?>" class="btn btn-white">
                                            <i class="fas fa-angle-left"></i>
                                        </a>
                                        <? } ?>
                                        <p class="text-muted d-md-inline-block bold mt-auto mb-auto">
                                            <span class="text-primary"> <?=$pageNow?> </span> / <?=$pageTotal?>
                                        </p>
                                        <? if($pageNow==$pageTotal){ ?>
                                        <a class="btn btn-white disabled"><i class="fas fa-angle-right"></i></a>
                                        <? }else{ ?>
                                        <a href="?pagenow=<?=$rempagenow+1?>&searchvalue=<?=$remsearchvalue?>&check=<?=$_SESSION['checkCate']?>" class="btn btn-white">
                                            <i class="fas fa-angle-right"></i>
                                        </a>
                                        <? } ?>
                                        <form method="get">
                                            <span class="bold">跳转到</span>
                                            <input type="hidden" value="<?=$remsearchvalue?>" name="searchvalue" >
                                            <input type="hidden" value="<?=$_SESSION['checkCate'] ?>" name="check">
                                            <input type="hidden" value="<?=$_SESSION['filter']?>" name="filter">
                                            <select name="pagenow">
                                                <?for($i=1;$i<=$pageTotal;++$i){?>
                                                <? if($i==$pageNow){?>
                                                <option value="<?=$i?>" selected><?=$i?></option>
                                                <? }else{ ?>
                                                <option value="<?=$i?>"><?=$i?></option>
                                                <?}?>
                                                <?}?>
                                            </select>
                                            <span class="bold">页</span>
                                            <button type="submit" class="btn pl-3 pr-3 pt-2.5 pb-2.5 btn-sm btn-primary squer-btn d-md-inline-block" >
                                                <i class="fas fa-sync-alt"></i>
                                            </button>
                                        </form>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <? }?>
                    </div>
                </div>
                <div class="email-content">
                    <div class="table-responsive">

                        <? if($ListTotal>0){?>

                        <table class="table table-inbox table-hover">

                            <!--显示信箱的格式-->
                            <? if(empty($_SESSION['checkCate'])||$_SESSION['checkCate']=='star'){?>
                            <? foreach($showResult as $key=>$val ){ ?>
                            <? if($key==0){ ?>
                            <thead>
                            <tr>
                                <th> # </th>
                                <th class="name">学号/工号</th>
                                <th class="name">发送人姓名</th>
                                <th class="subject" width="20%">消息主题</th>
                                <th class="subject" width="30%">消息内容</th>
                                <th class="mail-date">发送时间</th>
                                <th>查阅</th>
                                <th>收藏</th>
                            </tr>
                            </thead>
                            <tbody>
                            <? } ?>
                            <?if($val[7]){?>
                                <tr>
                            <?}else{?>
                                <tr class="unread" >
                            <?}?>
                                <td>
                                    <div class="checkbox checkbox-inbox">
                                        <input id="<?=$val[0]?>" type="checkbox" name="messBoxList" value="<?=$val[0]?>">
                                        <label for="<?=$val[0]?>"></label>
                                    </div>
                                </td>
                                <td class="name"><?=$val[3] ?></td>
                                <td class="name"><?=$val[8] ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[1],15) ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[2],25) ?></td>
                                <td class="mail-date"><?=$val[6]?></td>
                                <td class="acbt">
                                    <form method="post" action="./browsemess.php">
                                        <input type="hidden" name="messageID" value="<?=$val[0]?>" >
                                        <button type="submit"><i class="fas fa-envelope-open-text"></i></button>
                                    </form>
                                </td>
                                <td class="acbt" >
                                    <? if($val[5]==1){?>
                                    <form method="get" action="./messaction.php">
                                        <input type="hidden" name="action" value="unstar" >
                                        <input type="hidden" name="dealwitharray" value="<?=$val[0]?>" >
                                        <button type="submit" title="取消收藏">
                                            <span class="text-warning">
                                                <i class="fas fa-star starred"></i>
                                            </span>
                                        </button>
                                        <?}else{?>
                                        <form method="get" action="./messaction.php">
                                            <input type="hidden" name="action" value="star" >
                                            <input type="hidden" name="dealwitharray" value="<?=$val[0]?>" >
                                            <button type="submit" title="点击收藏">
                                            <span class="mail-important">
                                                <i class="far fa-star"></i>
                                            </span>
                                            </button>
                                            <?}?>
                                        </form>
                                </td>
                            </tr>
                            <? } ?>
                            </tbody>
                            <? } ?>

                            <!--草稿显示的格式-->
                            <? if($_SESSION['checkCate']=='save'){?>
                            <? foreach($showResult as $key=>$val ){ ?>
                            <? if($key==0){ ?>
                            <thead>
                            <tr>
                                <th class="name">学号/工号</th>
                                <th class="name">接收人姓名</th>
                                <th class="subject" width="25%">消息主题</th>
                                <th class="subject" width="40%">消息内容</th>
                                <th class="text-center">编辑</th>
                                <th class="text-center">删除</th>
                            </tr>
                            </thead>
                            <tbody>
                            <? } ?>
                                <tr class="save acbt">
                                    <td class="name"><?=empty($val[4]) ? '<span>待填写</sapn>':$val[4] ?></td>
                                    <td class="name"><?=empty($val[8]) ? '<span>未知</sapn>':$val[8] ?></td>
                                    <td class="subject text-nowrap"><?=empty($val[1]) ? '<span>待填写</sapn>': textsub($val[1],15) ?></td>
                                    <td class="subject text-nowrap"><?=empty($val[2]) ? '<span>待填写</sapn>': textsub($val[2],30) ?></td>
                                    <td class="text-center">
                                        <form method="post" action="./sendmess.php">
                                            <input type="hidden" name="mid" value="<?=$val[0]?>" >
                                            <input type="hidden" name="gettoid" value="<?=$val[4]?>">
                                            <input type="hidden" name="sendtitle" value="<?=$val[1]?>">
                                            <input type="hidden" name="sendcontent" value="<?=textsub($val[2],mb_strlen($val[2]))?>">
                                            <button type="submit"><i class="fas fa-pen"></i></button>
                                        </form>
                                    </td>
                                    <td class="text-center">
                                        <a class="save" onclick="mulActionDelMessage('del','<?=$val[0]?>','<?=$ListTotal ?>','<?=$pageTotal?>')" href="#">
                                            <i class="fas fa-times-circle"></i>
                                        </a>
                                    </td>
                                </tr>
                            <? } ?>
                            </tbody>
                            <? } ?>

                            <!--已发送显示的格式-->
                            <? if($_SESSION['checkCate']=='send'){?>
                            <? foreach($showResult as $key=>$val ){ ?>
                            <? if($key==0){ ?>
                            <thead>
                            <tr>
                                <th class="name">学号/工号</th>
                                <th class="name">接收人姓名</th>
                                <th class="subject" width="20%">消息主题</th>
                                <th class="subject" width="35%">消息内容</th>
                                <th class="mail-date">发送时间</th>
                                <th>查阅</th>
                            </tr>
                            </thead>
                            <tbody>
                            <? } ?>
                            <tr class="acbt">
                                <td class="name"><?=$val[4] ?></td>
                                <td class="name"><?=$val[8] ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[1],15) ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[2],30) ?></td>
                                <td class="mail-date"><?=$val[6]?></td>
                                <td>
                                    <form method="post" action="./browsemess.php">
                                        <input type="hidden" name="messageID" value="<?=$val[0]?>" >
                                        <button type="submit"><i class="fas fa-envelope-open-text"></i></button>
                                    </form>
                                </td>
                            </tr>
                            <? } ?>
                            </tbody>
                            <? } ?>


                            <!--显示回收站的格式-->
                            <? if($_SESSION['checkCate']=='trash'){?>
                            <? foreach($showResult as $key=>$val ){ ?>
                            <? if($key==0){ ?>
                            <thead>
                            <tr>
                                <th> # </th>
                                <th class="name">学号/工号</th>
                                <th class="name">发送人姓名</th>
                                <th class="subject" width="20%">消息主题</th>
                                <th class="subject" width="30%">消息内容</th>
                                <th class="mail-date">发送时间</th>
                                <th>查阅</th>
                            </tr>
                            </thead>
                            <tbody>
                            <? } ?>
                            <?if($val[7]){?>
                            <tr>
                                <?}else{?>
                            <tr class="unread" >
                                <?}?>
                                <td>
                                    <div class="checkbox checkbox-inbox">
                                        <input id="<?=$val[0]?>" type="checkbox" name="messBoxList" value="<?=$val[0]?>">
                                        <label for="<?=$val[0]?>"></label>
                                    </div>
                                </td>
                                <td class="name"><?=$val[3] ?></td>
                                <td class="name"><?=$val[8] ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[1],15) ?></td>
                                <td class="subject text-nowrap"><?=textsub($val[2],25) ?></td>
                                <td class="mail-date"><?=$val[6]?></td>
                                <td class="acbt">
                                    <form method="post" action="./browsemess.php">
                                        <input type="hidden" name="messageID" value="<?=$val[0]?>" >
                                        <button type="submit"><i class="fas fa-envelope-open-text"></i></button>
                                    </form>
                                </td>
                            </tr>
                            <? } ?>
                            </tbody>
                            <? } ?>


                        </table>

                        <? }else{ ?>
                        <h5 class="mb-3 bold text-center">无此类消息</h5>
                        <? }?>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>